cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

find_package(HDF4 REQUIRED)
include_directories(${HDF4_INCLUDE_DIRS})
set(LIBS ${HDF4_LIBRARIES})

find_package(PGSTK REQUIRED)
include_directories(${PGSTK_INCLUDE_DIRS})
list(APPEND LIBS ${PGSTK_LIBRARIES})

find_package(LibH4metadata REQUIRED)
include_directories(${LibH4metadata_INCLUDE_DIRS})
list(APPEND LIBS ${LibH4metadata_LIBRARIES})

add_executable(l1bgen_modisa
  L1B.c
  Preprocess.c
  L1B_Tables.c
  Granule.c
  HDF_Lib.c
  Metadata.c
  Reflective_Cal.c
  Emissive_Cal.c
  L1B_Setup.c
)

add_definitions(-DALLOW_MISSING_GRANULES -DNOCHECKLUT -DSEADAS -Wno-unused-local-typedefs)

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 
  set(CMAKE_EXE_LINKER_FLAGS "-Wl,-stack_size -Wl,0x8000000")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 
 
target_link_libraries(l1bgen_modisa
  ${LIBS}
)

install (TARGETS l1bgen_modisa DESTINATION bin)

